package gupao.concurrency.kms;

import gupao.concurrency.utils.RSAUtil;

import static gupao.concurrency.kms.KeyHolderMock.getPrivateKey;
import static gupao.concurrency.kms.KeyHolderMock.getPublicKey;

public interface RequestValidator {

    boolean validateRequest(RequestModel request, String rf);

    default boolean requestSignValidate(RequestModel request, String rf){
        return RSAUtil.verify(request.getJoinedReqParamStr(),
                getPublicKey(rf), request.getSignature());
    }

    default String decryptReqId(String encryptedId){
        return RSAUtil.decrypt(encryptedId, getPrivateKey());
    }
}
